/**
 * 
 */
package com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.rank;

import com.alstudio.module.xmpp.protocol.xmpp.packact.ALXmppDomainConfig;
import com.alstudio.module.xmpp.protocol.xmpp.packact.IQNameSpace;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.AlXmlTag;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate;

/**
 * @author alonso lee
 * 
 */
public class RankIQCreator extends BaseIQTemplate {

	private String start, end;
	private final int type;

	/**
	 * 
	 */
	public RankIQCreator(String start, String end, int type, String domain) {
		// TODO Auto-generated constructor stub
		this.start = start;
		this.end = end;
		this.domain = domain;
		this.type = type;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate
	 * #getIQXml()
	 */
	@Override
	public String getIQXml() {
		// TODO Auto-generated method stub
		String ns = IQNameSpace.NS_RANKING_GLAMOUR;
		switch (type) {
		case 1:
			// 富豪榜
			ns = IQNameSpace.NS_RANKING_RICH;
			break;
		case 2:
			// 女神榜
			ns = IQNameSpace.NS_RANKING_SEXY;
			break;
		}
		to = ALXmppDomainConfig.getALXmppDomainConfig()
				.getDomainByNameSpace(ns);
		mALIQCreator.setTo(to + domain);
		mALIQCreator.setNs(ns);
		mALIQCreator.setType(IQ_TYPE_GET);

		AlXmlTag indexTag = new AlXmlTag("index");
		indexTag.setAtt("start", start);
		indexTag.setAtt("end", end);
		tagList.add(indexTag);
		mALIQCreator.setTagList(tagList);
		String xml = "";
		try {
			xml = mALIQCreator.getXml();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return xml;
	}

}
